window.addEventListener('load', function () {
    /* 获取每个视频 */
    let video = document.querySelectorAll('.video-content');
    /* 获取p标签的集合 */
    let pc = document.getElementsByTagName('p');
    /* 获取播放按钮 */
    let pausew=this.document.querySelectorAll('.pause-w');
    let pauseb=this.document.querySelectorAll('.pause-b');
    /* 视频的文字介绍鼠标移动上去出现*/
    for (let i = 0; i < video.length; i++) {
        video[i].addEventListener('mouseenter', function () {
            pc[i].style.display = 'block';
            pausew[i].style.display='block';
            pauseb[i].style.display='none';
        })
        video[i].addEventListener('mouseleave', function () {
            pc[i].style.display = 'none';
            pauseb[i].style.display='block';
            pausew[i].style.display='none';
        })
    }

    /* 透明亮度的改变 */

    for(let n=0;n<video.length;n++){
        video[n].addEventListener('mouseenter',function(){
            video[n].style.opacity=1;
        })
        video[n].addEventListener('mouseleave',function(){
            video[n].style.opacity=0.6;
        })
    }

    

        /* 两个视频页面的切换 */
    let main1 = document.querySelector('.video-main');
    let main2 = document.querySelector('.video-main2');
    let videoal = document.querySelector('.video-al');
    let videoar = document.querySelector('.video-ar');
    let y = 0;
    let main = document.getElementById('.divul');
    let mainlength = main1.offsetWidth;

    videoar.addEventListener('click',function(){
        main1.style.display='none';
        main2.style.display='block';
    })
    videoal.addEventListener('click',function(){
        main2.style.display='none';
        main1.style.display='block';
    })
    /* function animate(obj, target) {
        clearInterval(obj.timer); 
        obj.timer = setInterval(function () {
            var step = ((target - obj.offsetLeft) / 10);
            step = step > 0 ? Math.ceil(step) : Math.floor(step);
            if (obj.style.left == target) {
                clearInterval(obj.timer);
            }
            obj.style.left = obj.offsetLeft + step + 'px';
        }, 20)
    }
    videoar.addEventListener('click',function(){
        y++;
        if(y>1){
            y=0;
        }
        animate(main,-y*mainlength);
    })
    
    videoal.addEventListener('click',function(){
        y--;
        if(y<0)y=1;
        console.log(y)
        animate(main,-y*mainlength); */
    /* if(index==0){
        main1.style.display='block';
        main2.style.display='none';
    }else if(index==1){
        main1.style.display='none';
        main2.style.display='block';
    } */
    /*})*/
})
